-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding metal_utils for iree_utils #1561
Conversation
shark/iree_utils/metal_utils.py
Outdated
@@ -0,0 +1,176 @@ | |||
# Copyright 2020 The Nod Team. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2023
shark/iree_utils/metal_utils.py
Outdated
# Adreno Targets | ||
elif all(x in device_name for x in ("Adreno", "740")): | ||
triple = f"adreno-a740-{system_os}" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove everything but the apple targets.
shark/iree_utils/metal_utils.py
Outdated
res_metal_flag = [] | ||
metal_triple_flag = None | ||
for arg in extra_args: | ||
if "-iree-metal-target-triple=" in arg: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see https://discord.com/channels/689900678990135345/1097586660495065178/1118622069547077653
I think you want --iree-metal-target-platform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix that
…od-ai#1559) -- It also modifies the mega_test.py script Signed-off-by: Abhishek Varma <[email protected]>
…i#1560) * Fix deprecation warning for unet config. * Include PIL metadata instead of hidden imports in SD spec.
apps/stable_diffusion/shark_sd.spec
Outdated
@@ -19,6 +19,7 @@ datas += copy_metadata('importlib_metadata') | |||
datas += copy_metadata('torch-mlir') | |||
datas += copy_metadata('omegaconf') | |||
datas += copy_metadata('safetensors') | |||
datas += copy_metadata('Pillow') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is already in tree ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a git pull before pushing, realized later I should not have done that. So I got 2 commits from Ean and Abhishek
Please update the branch |
Please run lint with black |
Wanted to let you know, there are also some changes I was trying, to get stable diffusion running. (i.e. adding checks for metal device and metal flags). Let me know if they should be removed from here |
shark/iree_utils/metal_utils.py
Outdated
|
||
|
||
def get_metal_device_name(device_num=0): | ||
vulkaninfo_dump, _ = run_cmd("vulkaninfo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this wont work. I used
(shark.venv) ➜ web git:(main) ✗ sysctl -a | grep brand
machdep.cpu.brand_string: Apple M1 Ultra
But I think Lei suggested using --dump_devices
shark/iree_utils/metal_utils.py
Outdated
print( | ||
f"Found metal device {metal_device}. Using metal target triple {triple}" | ||
) | ||
return f"-iree-metal-target-triple={triple}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be -iree-metal-target-platform=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, missed that one
Will fix it, and the vulkaninfo
ok to have the SD fixups too. |
Please uninstall the VulkanSDK and vulkaninfo from your device to test :D |
I don't know how I can change this, since it returns
|
For compile you still use vulkan |
Added metal_utils.py, changes IREE_DEVICE_MAP and IREE_TARGET_MAP to use metal, added a separate case to handel for metal device in compile_uitls.py
Passes 14 test using pytest -k metal, skips 16, xfail 16